<template>
	<view>
		<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scroll="scroll">
			<uni-table border stripe emptyText="暂无更多数据" @selection-change="selectionChange">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th :width="50" align="center">组别</uni-th>
					<uni-th :width="50" align="center">指令</uni-th>
					<uni-th :width="50" align="center">类型</uni-th>
					<uni-th :width="60" align="center">缴库日期</uni-th>
					<uni-th :width="60" align="center">缴库数量</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				<uni-tr v-for="item in tableList" @tap="batchReporting(item)">
					<uni-td>{{ item.deptName }}</uni-td>
					<uni-td>{{ item.lotNo }}</uni-td>
					<uni-td>{{ item.orderType2 }}</uni-td>
					<uni-td>{{ item.slipDate }}</uni-td>
					<uni-td>{{ item.qty }}</uni-td>
				</uni-tr>
			</uni-table>
		</scroll-view>
		<!-- <uv-button class="btn" type="primary" text="批量报产" @click="batchReporting"></uv-button> -->

		<uv-tabbar iconSize="30" :border="false" :value="tabbarValue" @change="tabbarChange">
			<uv-tabbar-item text="报产作业" icon="order"></uv-tabbar-item>
			<uv-tabbar-item text="产值查询" icon="search"></uv-tabbar-item>
			<uv-tabbar-item text="退出" icon="play-right"></uv-tabbar-item>
		</uv-tabbar>
		<uv-notify ref="notify" type="error"></uv-notify>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabbarValue: 0,
				searchObj: {},
				tableList: [],
				selectedIndexs: [],
				selectList: [], //选择的数据
				scrollTop: 0,
				old: {
					scrollTop: 0,
				},
			};
		},
		methods: {
			scroll: function(e) {
				// console.log(e)
				this.old.scrollTop = e.detail.scrollTop;
			},
			// 多选
			selectionChange(e) {
				console.log(e.detail);
				this.selectedIndexs = e.detail.index;
			},
			batchReporting(row) {
				uni.request({
					url: '/kl/pad/stitchProductionReport/getNotReportProcessDetails',
					header: {
						'Authorization': uni.getStorageSync('token'), //自定义请求头信息
					},
					data: row,
					method: "POST",
					success: (res) => {
						if (res.data.code === 200) {
							for (let i = 0; i < res.data.data.list.length; i++) {
								res.data.data.list[i].qty4 = res.data.data.list[i].qty3
							}
							uni.navigateTo({
								url: "/pages/batchReporting/batchReporting?selectList=" + JSON
									.stringify(res.data.data.list) + "&selectRow=" + JSON.stringify(
										row) + "&searchObj=" + JSON.stringify(this
										.searchObj),
							});
						} else {
							this.$refs.notify.show({
								message: res.data.message
							});
						}
					}
				});

				// uni.request({
				// 	url: "/kl/pad/stitchProductionReport/getNotReportProcessDetails",
				// 	header: {
				// 		Authorization: uni.getStorageSync("token"), //自定义请求头信息
				// 	},
				// 	data: [row],
				// 	method: "POST",
				// 	success: (res) => {
				// 		console.log(res);
				// 		if (res.data.code === 200) {
				// 			for (let i = 0; i < res.data.data.list.length; i++) {
				// 				res.data.data.list[i].qty4 = res.data.data.list[i].qty3
				// 			}
				// 			uni.navigateTo({
				// 				url: "/pages/batchReporting/batchReporting?selectList=" + JSON
				// 					.stringify(res.data.data.list) + "&selectRow=" + JSON.stringify(
				// 						row) + "&searchObj=" + JSON.stringify(this
				// 					.searchObj),
				// 			});
				// 		} else {
				// 			this.$refs.notify.show({
				// 				message: res.data.message,
				// 			});
				// 		}
				// 	},
				// });
			},
			tabbarChange(index) {
				this.tabbarValue = index;
				if (index === 0) {
					uni.reLaunch({
						url: "/pages/index/index",
					});
				}
				if (index === 2) {
					uni.reLaunch({
						url: "/pages/login/login",
					});
				}
			},
			getTableList() {
				console.log(this.searchObj);
				uni.request({
					url: "/kl/pad/stitchProductionReport/getNotReportProductDetails",
					header: {
						Authorization: uni.getStorageSync("token"), //自定义请求头信息
					},
					data: {
						...this.searchObj,
						pageNum: 1,
						pageSize: 9999,
					},
					method: "POST",
					success: (res) => {
						console.log({
								...this.searchObj,
								pageNum: 1,
								pageSize: 9999,
							},
							res
						);
						if (res.data.code === 200) {
							this.tableList = res.data.data.list;
						} else {
							this.$refs.notify.show({
								message: res.data.message,
							});
						}
					},
				});
			},
		},
		onLoad(data) {
			console.log(22222222, data)
			this.searchObj = data;
		},
		onShow() {
			this.getTableList();
		},
	};
</script>

<style>
	.btn {
		margin: 30rpx;
	}

	.scroll-Y {
		height: 85vh;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
	}

	.scroll-view-item {
		height: 81vh;
		line-height: 81vh;
		text-align: center;
		font-size: 36rpx;
	}

	.scroll-view-item_H {
		display: inline-block;
		width: 100%;
		height: 81vh;
		line-height: 81vh;
		text-align: center;
		font-size: 36rpx;
	}
</style>